<?php
namespace app\api\controller;

use think\Controller;
use think\Db;

class BaseController extends Controller
{
    protected $uid;
    protected $userData;
    public function __construct()
    {
        parent::__construct();
      	header("Access-Control-Allow-Origin: *");
      	header("Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE");
        header('Access-Control-Allow-Headers:x-requested-with,content-type');
        $this->openid();
    }
   	protected function openid()
    {
        $token = request()->post('token');
        if ($token == null) {
            AjaxReturn(10000, "信息错误！");
        }
        else{
            $data = Db::name('user')->where('token',$token)->find();
            if(!empty($data))
            {
                $this->uid = $data['id'];
            }else{
                AjaxReturn(10000, "信息错误！");
            }
        }
    }
}